package com.sinoglobal.wallet.view;

import com.sinoglobal.wallet.util.LogUtils;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ListView;

/**
 * 
 * @author jthou
 * @createdate 2015-8-17 上午9:55:51
 * @Description: 用于ScrollView嵌套的ListView
 */
public class InnerListView extends ListView {
	
	public InnerListView(Context context) {
		super(context);
	}


	public InnerListView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public InnerListView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}
	
	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
		
		int count = getChildCount();//得到子view的数目，再循环遍历出子view
		if(count <= 5) return;
		// measureChildren(widthMeasureSpec, heightMeasureSpec);
		int height = 0;
		for (int i = 0; i < 5; i++) {
			View child = getChildAt(i);//拿到index上的子view。 
			//某一个子view，多宽，多高, 内部加上了viewGroup的padding值
			measureChild(child, widthMeasureSpec, heightMeasureSpec);
			height += child.getHeight();
		}
		LogUtils.v("onMeasure------------------");
		setMeasuredDimension(getMeasuredWidth(), height);
	
	}
}
